package com.eco.fanliapp.admin.controller.web;


import com.eco.fanliapp.admin.annotation.SysLogAnnotation;
import com.eco.fanliapp.admin.common.BaseController;
import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.service.ISySwitchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 开关表 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2019-08-28
 */
@RestController
@RequestMapping("/web/sySwitch")
public class SySwitchController extends BaseController {

	@Autowired
	private ISySwitchService sySwitchService;



	/**
	 * 开关列表
	 * @param switchId  开关id
	 * @param switchName  开关名称
	 * @return
	 */
	@GetMapping("/findSwitchList")
	@ResponseBody
	public ServerResponse findSwitchList(Integer switchId, String switchName){

		return sySwitchService.findSwitchList(switchId,switchName);
	}

	/**
	 * 开关新增
	 * @param platform
	 * @param switchName
	 * @param state
	 * @return
	 */
	@PostMapping("/createSwitch")
	@ResponseBody
	public ServerResponse createSwitch(Integer platform, String switchName, Integer state,String switchDesc){

		return sySwitchService.createSwitch(platform,switchName,state,switchDesc);
	}

	/**
	 * 修改/删除 开关
	 * @param switchId
	 * @param platform
	 * @param switchName
	 * @param state
	 * @param enable
	 * @param deleted
	 * @return
	 */
	@PostMapping("/updateOrDelSwitch")
	@ResponseBody
	public ServerResponse updateOrDelSwitch(Integer switchId, Integer platform, String switchName, String switchDesc, Integer state, Integer enable, Integer deleted){

		return sySwitchService.updateOrDelSwitch(switchId,platform,switchName,switchDesc,state,enable,deleted);
	}

	/**
	 * 修改开关状态
	 * @param switchId
	 * @param state
	 * @return
	 */
	@RequestMapping("/switchOff/update")
	@ResponseBody
	@SysLogAnnotation(value = "app开关管理",userType = 2)
	public ServerResponse switchOffUpdate(Integer switchId,Integer state){

		return sySwitchService.switchOffUpdate(switchId,state);
	}

	/**
	 * 开关列表
	 * @return
	 */
	@RequestMapping("/switchOff/list")
	@ResponseBody
	public ServerResponse switchOffList(){

		return sySwitchService.switchOffList();
	}
}
